<template>
  <transition name="loader-fade">
    <div v-if="loading" class="page-loader">
      <div class="loader-content">
        <div class="loader-icon">🤖</div>
        <div class="loader-spinner">
          <div class="spinner-ring"></div>
          <div class="spinner-ring"></div>
          <div class="spinner-ring"></div>
        </div>
        <div class="loader-text">加载中...</div>
      </div>
    </div>
  </transition>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const loading = ref(true)

onMounted(() => {
  // 模拟页面加载完成
  const handleLoad = () => {
    setTimeout(() => {
      loading.value = false
    }, 500)
  }

  if (document.readyState === 'complete') {
    handleLoad()
  } else {
    window.addEventListener('load', handleLoad)
  }
})
</script>

<style scoped>
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0f1e 0%, #1a1f35 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  backdrop-filter: blur(10px);
}

.loader-content {
  text-align: center;
  position: relative;
}

.loader-icon {
  font-size: 5rem;
  animation: bounce 1s ease-in-out infinite;
  margin-bottom: 2rem;
  filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.8));
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-20px) rotate(-10deg);
  }
  75% {
    transform: translateY(-10px) rotate(10deg);
  }
}

.loader-spinner {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 2rem;
}

.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-radius: 50%;
  animation: spin 2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
  border-top-color: var(--neon-blue);
  animation-delay: -0.45s;
  box-shadow: 0 0 20px var(--neon-blue);
}

.spinner-ring:nth-child(2) {
  border-top-color: var(--neon-purple);
  animation-delay: -0.3s;
  box-shadow: 0 0 20px var(--neon-purple);
}

.spinner-ring:nth-child(3) {
  border-top-color: var(--neon-pink);
  animation-delay: -0.15s;
  box-shadow: 0 0 20px var(--neon-pink);
}

@keyframes spin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(0.8);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

.loader-text {
  font-size: 1.5rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple), var(--neon-pink));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-slide 2s ease infinite;
}

@keyframes gradient-slide {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.loader-fade-enter-active,
.loader-fade-leave-active {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.loader-fade-enter-from {
  opacity: 0;
  transform: scale(0.9);
}

.loader-fade-leave-to {
  opacity: 0;
  transform: scale(1.1);
}
</style>


